/**
 * 转换播放数量单位为：万
 * @param count 数量
 * @returns 转换后
 */
export const convertCount = (sum: number): string | number | undefined => {
	if (sum === 0) return;

	if (sum >= 100000000) {
		return (sum / 100000000).toFixed(2) + "亿";
	} else if (sum >= 10000) {
		return (sum / 10000).toFixed(1) + "万";
	} else {
		return sum;
	}
};

/**
 * 获取 [min,max]的随机数
 * Math.floor(Math.random()*10) 可均衡获取 0 到 9 的随机整数
 * @param min
 * @param max
 */
export const getRandomIndex = (min: number, max: number): number => {
	return Math.floor(Math.random() * (max - min + 1) + min) ?? 0;
};

/**
 * //判断是安卓还是ios
 */
export const systemInfo = () => {
	let devlType = "";
	switch (uni.getSystemInfoSync().platform) {
		case "android":
			devlType = "android";
			break;
		case "ios":
			devlType = "ios";
			break;
		default:
			devlType = "ios";
			break;
	}
	return devlType;
};

/**
 * showToast-提示
 */
export const msg = (title: string, duration: number = 1500, mask: boolean = false, icon: any = "none") => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
};
